﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Controls;

namespace MediaPad.Resources
{
    public class InkCanvasEditingModeToBool : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            InkCanvasEditingMode mode = (InkCanvasEditingMode)value;

            switch (parameter.ToString())
            {
                case "Ink":

                    return mode == InkCanvasEditingMode.Ink;

                case "GestureOnly":

                    return mode == InkCanvasEditingMode.GestureOnly;

                case "InkAndGesture":

                    return mode == InkCanvasEditingMode.InkAndGesture;

                case "Select":

                    return mode == InkCanvasEditingMode.Select;

                case "EraseByPoint":

                    return mode == InkCanvasEditingMode.EraseByPoint;

                case "EraseByStroke":

                    return mode == InkCanvasEditingMode.EraseByStroke;

                default:
                    
                    return mode == InkCanvasEditingMode.None;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool hasValue = (bool)value;
            if(hasValue)
            {
                switch (parameter.ToString())
                {
                    case "Ink":

                        return InkCanvasEditingMode.Ink;

                    case "GestureOnly":

                        return InkCanvasEditingMode.GestureOnly;

                    case "InkAndGesture":

                        return InkCanvasEditingMode.InkAndGesture;

                    case "Select":

                        return InkCanvasEditingMode.Select;

                    case "EraseByPoint":

                        return InkCanvasEditingMode.EraseByPoint;

                    case "EraseByStroke":

                        return InkCanvasEditingMode.EraseByStroke;

                    default:

                        return InkCanvasEditingMode.None;
                }
            }

            return InkCanvasEditingMode.None;
        }

        #endregion
    }
}
